package sort;

import java.util.Arrays;

public class SelectionSort {
    public static void selectSort2(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            int k = i;
            int min = arr[i];
            for (int j = i+1; j < arr.length; j++) {
                if(arr[j]<min){
                    min = arr[j];
                    k = j;
                }
            }
            if(k!=i){
                int temp = arr[i];
                arr[i] = arr[k];
                arr[k] = temp;
            }
        }
    }

    public static void main(String[] args) {
        int[] a = {39,4,564,345,667,3,45,6,67,8,34,5,1,41};
        selectSort2(a);
        System.out.println(Arrays.toString(a));
    }
}
